package com.example.demo.service;

import com.example.demo.dao.SaleMangeMapper;
import com.example.demo.entity.CommonResult;
import com.example.demo.entity.Salesrecord;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SaleMangeService implements SaleMangeimpl{

    @Autowired
    SaleMangeMapper saleMangeMapper;
    @Override
    public CommonResult GetOnepagesale(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Salesrecord> getallsalerecord = saleMangeMapper.Getallsalerecord();
        if (getallsalerecord.size() <= 0) {
            return new CommonResult(200, "暂时没有销售记录");
        }
        PageInfo pageInfo = new PageInfo(getallsalerecord);
        return new CommonResult(200, "销售记录第" + pageInfo.getPageNum() + "页获取成功", pageInfo);
    }

    @Override
    public CommonResult selectsalegoods(String drug_id, String sale_time) {
        List<Salesrecord> selectsalegoods = saleMangeMapper.selectsalegoods(drug_id, sale_time);
        return new CommonResult(200,"销售信息",selectsalegoods);
    }
}
